package com.central.user.mq

import com.central.user.service.ISysUserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.stream.annotation.StreamListener
import org.springframework.stereotype.Service

/**
 * @author  fly
 * @date  2021/6/2 16:06
 * @version 1.0
 */
@Service
open class UserMqSubscribeService {

    @Autowired
    private lateinit var userService: ISysUserService


    @StreamListener(integralInput)
    fun subscribeIntegralInput(userId: String) {

        userService.getById(userId)?.run {
            integral += 5
            userService.updateById(this)
        }
    }
}